#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct Apple {
	int height;
	int force;
};
bool cmp(Apple a1, Apple a2)
{
	return a1.force < a2.force;
}
int main()
{
	int n, s;
	cin >> n >> s;

	int a, b;
	cin >> a >> b;

	vector<Apple> apples(n);
	for (int i = 0; i < n; i++) {
		cin >> apples[i].height >> apples[i].force;
	}

	int count = 0;
	sort(apples.begin(), apples.end(), cmp);
	for (int i = 0; i < n; i++) {
		if (apples[i].height <= a + b && apples[i].force <= s) {
			count++;
			s -= apples[i].force;
		}
	}

	cout << count << endl;

	return 0;
}
